package de.dhbw.asa.controller;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import de.dhbw.asa.model.Adress;
import de.dhbw.asa.model.Customer;

@ManagedBean
@SessionScoped
public class AdressCtrl 
{

	@ManagedProperty(value ="#{customer}")
	Customer customer;
	
	@ManagedProperty(value ="#{orderCtrl}")
	OrderCtrl orderCtrl;
	
	
	public String insertNewAdress(Adress jCurrent)
	{
		String sReturn = "failure";
		if (jCurrent.saveNewAdress(customer, jCurrent.getsStreet(), jCurrent.getsHouseNr(), jCurrent.getiPostcode(), jCurrent.getsCountry(), jCurrent.getsCity()).equals(""))
		{
			customer.jAdressList.add(jCurrent);
			sReturn = "success";
		}
		return sReturn;
	}


	public Customer getCustomer() {
		return customer;
	}


	public void setCustomer(Customer customer) {
		this.customer = customer;
	}


	public OrderCtrl getOrderCtrl() {
		return orderCtrl;
	}


	public void setOrderCtrl(OrderCtrl orderCtrl) {
		this.orderCtrl = orderCtrl;
	}
	
	
	
}
